fix: fix value bit corruption in right_shift#348
Merged
apoelstra merged 2 commits intoBlockstreamResearch:masterfrom Mar 3, 2026
Merged
fix: fix value bit corruption in right_shift#348apoelstra merged 2 commits intoBlockstreamResearch:masterfrom
apoelstra merged 2 commits intoBlockstreamResearch:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Yet another option to solve #337
The tests are actually generated by Claude. The comments are a bit wordy, so happy to try clean it up if it bothers anyone.
The interesting thing to note is that the bug is not as a result of
from_padded_bits, as apoelstra (and myself) suspected. Upon adding the two regression tests from #339,prune_regression_337_1still fails, indicating another bug infrom_padded_bits.However,
prune_regression_337_2passes on this PR without any changes tofrom_padded_bits. The tests added in this PR also reproduce the error without callingfrom_padded_bits.I have also tried to keep the optimization of not cloning the array if the bit is already equal to
new_bitand added it to the true case as well.For those interested here are the before and after benchmarks. Nothing jumps out at me as a huge improvement or degradation.
BEFORE (Commit f84b09d)
AFTER (c70e3ed)